import request from 'UTIL/request'

/**
 * 合同列表
 * @param params
 */
export function GetList(params) {
  return request({
    url: 'crmContract/queryPageList',
    method: 'POST',
    data: params
  })
}

/**
 * 合同详情
 * @param params
 */
export function QueryById(params) {
  return request({
    url: `crmContract/queryById/${params.contractId}`,
    method: 'POST',
    data: params
  })
}

/**
 * 基本信息
 */
export function InformationById(params) {
  return request({
    url: `crmContract/information/${params.id}`,
    method: 'POST',
    data: params
  })
}

/**
 * 新增/编辑时查询字段
 */
export function QueryFieldList(params) {
  const query = params && params.id ? `/${params.id}` : ''
  return request({
    url: `crmContract/field${query}`,
    method: 'POST',
    data: params,
		requestType: 'form'
  })
}

/**
 * 合同创建
 */
export function AddContract(params) {
  return request({
    url: 'crmContract/add',
    method: 'POST',
    data: params
  })
}

/**
 * 合同编辑
 */
export function UpdateContract(params) {
  return request({
    url: 'crmContract/update',
    method: 'POST',
    data: params
  })
}

/**
 * 合同回款计划创建/编辑
 * @param params
 */
export function AddReceivedPlan(params) {
  return request({
    url: 'crm/ReceivablesPlan/saveAndUpdate',
    method: 'POST',
    data: params
  })
}

/**
 * 合同删除
 * @param params
 */
export function DeleteByIds(params) {
  return request({
    url: 'crmContract/deleteByIds',
    method: 'POST',
    data: params
  })
}

/**
 * 合同作废
 * @param params
 */
export function DiscardById(params) {
  return request({
    url: 'crmContract/contractDiscard',
    method: 'POST',
    data: params,
		requestType: 'form'
  })
}

/**
 * 合同转移
 * @param params
 */
export function ChangeOwnerUser(params) {
  return request({
    url: 'crmContract/changeOwnerUser',
    method: 'POST',
    data: params
  })
}

/**
 * 合同相关产品
 * @param params
 */
export function QueryProduct(params) {
  return request({
    url: 'crmContract/queryProductListByContractId',
    method: 'POST',
    data: params
  })
}

/**
 * 合同相关回款
 * @param params
 */
export function QueryReceivables(params) {
  return request({
    url: 'crmContract/qureyReceivablesListByContractId',
    method: 'POST',
    data: params
  })
}

/**
 * 合同相关回款计划
 * @param params
 */
export function QueryReceivablesPlanList(params) {
  return request({
    url: 'crmContract/queryReceivablesPlanListByContractId',
    method: 'POST',
    data: params
  })
}


/**
 * 合同下回款计划
 * @param params
 */
export function QueryReceivablesPlan(params) {
  return request({
    url: 'crmContract/queryReceivablesPlansByContractId',
    method: 'POST',
    data: params,
		requestType: 'form'
  })
}

/**
 * 合同相关团队
 * @param params
 */
export function GetMembers(params) {
  return request({
    url: `crmContract/getMembers/${params.id}`,
    method: 'POST'
  })
}

/**
 * 合同添加团队成员
 * @param params
 */
export function AddMembers(params) {
  return request({
    url: 'crmContract/addMembers',
    method: 'POST',
    data: params
  })
}

/**
 * 合同修改团队成员
 * @param params
 */
export function UpdateMembers(params) {
  return request({
    url: 'crmContract/updateMembers',
    method: 'POST',
    data: params
  })
}

/**
 * 合同删除团队成员
 * @param params
 */
export function DeleteMembers(params) {
  return request({
    url: 'crmContract/deleteMembers',
    method: 'POST',
    data: params
  })
}

/**
 * 合同跟进记录
 * @param params
 */
export function GetRecord(params) {
  return request({
    url: 'crmContract/getRecord',
    method: 'POST',
    data: params
  })
}

/**
 * 合同跟进记录
 * @param params
 */
export function AddRecord(params) {
  return request({
    url: 'crmContract/addRecord',
    method: 'POST',
    data: params
  })
}

/**
 * 查询合同下附件列表
 * @param params
 */
export function QueryFileList(params) {
  return request({
    url: 'crmContract/queryFileList',
    method: 'POST',
    data: params,
		header: {
			'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
  })
}
